//app.js
App({
  globalData:{
    DataBase:null,
    todayWeather:"",
    DataBaseCommand:null,
    openid:"",
    InitializePage:true,//是否显示初始化页面
    userName:"",//昵称
    moodItem: {},
    moodList: [{
      id: 0,
      name: '无语',
      str: 'wuyu',
      color: '#7FFFD4'
    },
    {
      id: 1,
      name: '要死',
      str: 'dead',
      color: '#52a398'
    },
    {
      id: 2,
      name: '期待',
      str: 'expect',
      color: '#f0e478'
    },
    {
      id: 3,
      name: '害怕',
      str: 'fear',
      color: '#3d647a'
    },
    {
      id: 4,
      name: '开心',
      str: 'happy',
      color: '#db6e84'
    },
    {
      id: 5,
      name: '流泪',
      str: 'tear',
      color: '#7DCAFA'
    },
    {
      id: 6,
      name: '生气',
      str: 'mad',
      color: '#aa66cc'
    },
    ]
  },
  onLaunch: function () {
    var _userName=wx.getStorageSync('userName');

    if (!wx.cloud) {
      console.error('请使用 2.2.3 或以上的基础库以使用云能力')
    } else {
      wx.cloud.init({
        traceUser: true,
      })
      this.globalData.DataBase=wx.cloud.database();
      this.globalData.DataBaseCommand=wx.cloud.database().command;

    }
    wx.cloud.callFunction({ //获取用户openid
      name: 'login',
      data: {},
      success: res => {
      this.globalData.openid=res.result.openid;
      }
    })
    
   if(_userName!="") 
   {
     this.globalData.InitializePage=false;
     this.globalData.userName=_userName;
   }
   //获取系统信息
   wx.getSystemInfo({ 
    success: e => { 
      this.globalData.Height=e.windowHeight; 
      this.globalData.StatusBar = e.statusBarHeight; 
      let custom = wx.getMenuButtonBoundingClientRect(); 
      this.globalData.Custom = custom; 
      this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight; 
    } 
  }) 
  }
})
